﻿using System;

namespace StateMachine
{
    public abstract class StateHandler<T>
        where T : struct
    {
        private readonly StateMachineContext<T> context;

        public StateHandler(StateMachineContext<T> context)
        {
            this.context = context;
        }

        protected StateMachineContext<T> Context
        {
            get
            {
                return this.context;
            }
        }

        internal void HandleInput(object input)
        {
            this.Context.State = this.HandleInputOverride(input);
        }

        protected abstract T HandleInputOverride(object input);
    }
}
